{extend name="public/base" /}

{block name="title"}<title>产品订单列表</title>{/block}

{block name="pjax_container"}
<style>
tr>th,td{
    text-align: center;

}
 
.content-header>.breadcrumb>li{
    color: #999;
}
.content-header>.breadcrumb>.active{
    color: #666;
}
.content-header{
    height: 51px;
 
}
.btn-primary{
      background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 5px 10px; 
}
.box-primary{
  border-top-color: #ecf0f5 !important;
  border-top-width: 16px;
  
}
.btn-primary:hover{
     background-color: #1890FF;
    color: #fff;
    border: none;
    opacity: .9;
    border-radius: 6px !important; 
}
.delete-one{
    background-color: ff4141 !important;
    margin-left: 15px;
    border-radius: 6px;
    padding: 5px 8px;
}
.sreachs{
       background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 7px 15px; 
}
</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li>订单管理</li>
        <li class="active">产品订单列表</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div style="margin: 10px;">
                    <span>今日订单金额:{$order_1}</span></br>
                    <span>本月订单金额:{$order_2}</span></br>
                    <span>累计订单金额:{$order_3}</span>
                </div>
                {include file="form_search/search_goods_order" /}
                <div class="box-header with-border">
                    <div class="pull-left">
                        {:authAction(CONTROLLER_NAME.'/index_del','delete_all')}
                        {:authAction(CONTROLLER_NAME.'/index_send_all','send_all')}
                    </div>
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover">
                        <tr>
                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                            <th>订单号</th>
                            <th>用户账号</th>
                            <th>联系电话</th>
                            <th>购买产品信息</th>
                            <th>订单金额</th>
                            <th>添加时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        {volist name="list_item" id="v"}
                        <tr>
                            <td><input type="checkbox" name="id[]" value="{$v.id}" class="minimal checkbox"></td>
                            <td>{$v["order_number"]}</td>
                            <td>{$v["account"]}</td>
                            <td>{$v["mobile"]}</td>
                            <td>
                                {volist name="$v['goods_list']" id="v1"}
                                产品名称:{$v1.name}
                                产品数量:{$v1.goods_num}
                                产品型号:{$v1.goods_model}
                                产品单价:{$v1.price}<br/>
                                {/volist}
                            </td>
                            <td>{$v["total_price"]}</td>
                            <td>{:date('Y-m-d',$v["create_time"])}</td>
                            {php}
                            if($v['status'] == 0){
                                $status = '待付款';
                            }elseif( $v['status'] == 1){
                                $status = '待发货';
                            }elseif( $v['status'] == 2){
                                $status = '待收货';
                            }elseif( $v['status'] == 3){
                                $status = '已完成';
                            }
                            {/php}
                            <td>{$status}</td>
                            <td style="width: 20%;">
                                {if condition="$v['status'] == 1"}
                                {:authAction(CONTROLLER_NAME.'/index_send','send',['id'=>$v['id']])}
                                {/if}
                                {:authAction(CONTROLLER_NAME.'/index_edit','edit',['id'=>$v['id']])}
                                {:authAction(CONTROLLER_NAME.'/index_del','delete_one',['id'=>$v['id']])}
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$list->render()}
                </div>
            </div>
        </div>
    </div>
</section>
<script>
    $(function(){
        // 列表部分 全选
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });
        $('.checkbox-toggle').on('ifChecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });
    });
    $('.send').on('click',function () {
        var id = $(this).attr('data-id');
        var url = "{:url('index')}";
        if (!confirm("确定发货？")){return false}
        $.ajax({
            url:"{:url('order_send')}",
            data:{'id':id},
            success:function (res) {
                if(res.code == 0){
                    //刷新页面
                    $.amaran({'message':res.msg});
                    $.pjax({'url': url, 'container': '#pjax-container', 'fragment':'#pjax-container'})
                    //window.location.reload();
                }else{
                    $.amaran({'message':res.msg});
                }

            }
        })
    })
</script>
{/block}
